/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.yingran.common.util;

import java.io.Serializable;
import java.util.Objects;

public class ParamsUtil {
    private static ParamsUtil instace;

    private ParamsUtil() {

    }

    public static ParamsUtil getInstance() {
        if (instace == null) {
            synchronized (ParamsUtil.class) {
                if (instace == null) {
                    instace = new ParamsUtil();
                }
            }
        }
        return instace;
    }


    public <F, S> ParamsTwo<F, S> create(F f, S s) {
        return new ParamsTwo<>(f, s);
    }

    public <F, S, T> ParamsThree<F, S, T> create(F f, S s, T t) {
        return new ParamsThree<>(f, s, t);
    }

    public static class ParamsTwo<F, S> {
        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            ParamsTwo<?, ?> paramsTwo = (ParamsTwo<?, ?>) o;
            return Objects.equals(first, paramsTwo.first) &&
                    Objects.equals(second, paramsTwo.second);
        }

        @Override
        public int hashCode() {

            return Objects.hash(first, second);
        }

        public F first;
        public S second;

        ParamsTwo(F first, S second) {
            this.first = first;
            this.second = second;
        }
    }

    public static class ParamsThree<F, S, T> implements Serializable{
        public F first;
        public S second;
        public T third;

        public ParamsThree(F first, S second, T third) {
            this.first = first;
            this.second = second;
            this.third = third;
        }

        @Override
        public String toString() {
            return "ParamsThree{" +
                    "first=" + first +
                    ", second=" + second +
                    ", third=" + third +
                    '}';
        }
    }


}
